//
//  CircleView.m
//  Tianmao
//
//  Created by dllo on 15/7/23.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "CircleView.h"
#import "DKNightVersion.h"
#import "UIImageView+NightImage.h"
@interface CircleView ()
@property (nonatomic, retain) UIImageView *picView;
@property (nonatomic, retain) UILabel *titleLabel;

@end

@implementation CircleView


-(void)dealloc{
    [_picView release];
    [_titleLabel release];
    [super dealloc];
}


-(instancetype)initWithFrame:(CGRect)frame
                   imageName:(NSString *)imageName
                       title:(NSString *)text
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [DKNightVersionManager addClassToSet:self.class];
        self.nightBackgroundColor = UIColorFromRGB(0x343434);
    
        self.picView = [[UIImageView alloc] init];
        self.picView.image =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imageName ofType:nil]];
        self.picView.nightImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imageName ofType:nil]];
        self.picView.backgroundColor = [UIColor cyanColor];
        self.picView.frame = CGRectMake((self.frame.size.width - 55) / 2, 10, 55,55);
        self.picView.layer.cornerRadius = self.picView.frame.size.width / 2;
        self.picView.layer.masksToBounds = YES;
        [self addSubview:self.picView];
        [_picView release];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.picView.frame.origin.x, self.picView.frame.origin.y + self.picView.frame.size.height + 5, self.frame.size.width,20)];
       
        self.titleLabel.text = text;
        self.titleLabel.nightTextColor = [UIColor whiteColor];
        self.titleLabel.font = [UIFont fontWithName:@"Marion" size:15];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.titleLabel];
        [_titleLabel release];
    }
    return self;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [(NSObject *)self.target performSelector:self.action withObject:self];
}

@end
